<template>
  <div class="recharge-container">
    <el-card class="recharge-card">
      <template #header>
        <div class="card-header">
          <span>账户充值</span>
        </div>
      </template>
      
      <el-form :model="rechargeForm" :rules="rules" ref="rechargeFormRef" label-width="100px">
        <el-form-item label="充值金额" prop="amount">
          <el-input-number 
            v-model="rechargeForm.amount" 
            :min="1" 
            :precision="2"
            :step="100"
            placeholder="请输入充值金额"
          />
        </el-form-item>
        
        <el-form-item label="支付方式" prop="paymentMethod">
          <el-select v-model="rechargeForm.paymentMethod" placeholder="请选择支付方式">
            <el-option label="支付宝" value="alipay" />
            <el-option label="微信支付" value="wechat" />
            <el-option label="银行卡" value="bank" />
          </el-select>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="handleRecharge">确认充值</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script setup>
import { ref, reactive } from 'vue'
import { ElMessage } from 'element-plus'

const rechargeFormRef = ref(null)

const rechargeForm = reactive({
  amount: 0,
  paymentMethod: ''
})

const rules = {
  amount: [
    { required: true, message: '请输入充值金额', trigger: 'blur' },
    { type: 'number', min: 1, message: '充值金额必须大于0', trigger: 'blur' }
  ],
  paymentMethod: [
    { required: true, message: '请选择支付方式', trigger: 'change' }
  ]
}

const handleRecharge = async () => {
  if (!rechargeFormRef.value) return
  
  await rechargeFormRef.value.validate((valid) => {
    if (valid) {
      // TODO: 实现充值逻辑
      ElMessage.success('充值请求已提交')
    } else {
      ElMessage.error('请检查输入信息')
      return false
    }
  })
}
</script>

<style scoped>
.recharge-container {
  padding: 20px;
}

.recharge-card {
  max-width: 600px;
  margin: 0 auto;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style> 